from enum import Enum

class BaseEnum(Enum):
    """枚举基类，提供通用功能"""
    
    @property
    def code(self):
        """获取状态码"""
        return self.value[0]
    
    @property
    def desc(self):
        """获取描述"""
        return self.value[1]
    
    @classmethod
    def get_desc_by_code(cls, code):
        """根据状态码获取描述"""
        for member in cls:
            if member.code == code:
                return member.desc
        return None
    
    @classmethod
    def get_enum_by_code(cls, code):
        """根据状态码获取枚举成员"""
        for member in cls:
            if member.code == code:
                return member
        return None
    
    @classmethod
    def get_all_codes(cls):
        """获取所有状态码"""
        return [member.code for member in cls]
    
    @classmethod
    def get_all_descs(cls):
        """获取所有描述"""
        return [member.desc for member in cls]

class CommonStatusEnum(BaseEnum):
    """通用状态枚举"""
    DISABLED = (0, "禁用")
    ENABLED = (1, "启用")

class EnableStatusEnum(BaseEnum):
    """启用/停用状态枚举"""
    DISABLED = (0, "停用")
    ENABLED = (1, "启用")

# 别名定义，提高语义清晰度
UserStatusEnum = CommonStatusEnum  # 用户状态
ClassroomStatusEnum = EnableStatusEnum  # 教室状态
CourseStatusEnum = EnableStatusEnum  # 课程状态
AcademicYearStatusEnum = EnableStatusEnum  # 学年状态

class StudentStatusEnum(BaseEnum):
    """学生状态枚举"""
    LEFT = (0, "离校")
    IN_SCHOOL = (1, "在校")

class TeacherStatusEnum(BaseEnum):
    """教师状态枚举"""
    RESIGNED = (0, "离职")
    ACTIVE = (1, "在职")

class ClassStatusEnum(BaseEnum):
    """班级状态枚举"""
    DISSOLVED = (0, "解散")
    NORMAL = (1, "正常")

class ClassStudentStatusEnum(BaseEnum):
    """班级学生状态枚举"""
    LEFT = (0, "已离开")
    STUDYING = (1, "在读")

class GenderEnum(BaseEnum):
    """性别枚举"""
    MALE = (1, "男")
    FEMALE = (2, "女")

class GradeEnum(BaseEnum):
    """年级枚举"""
    GRADE_1 = (1, "一年级")
    GRADE_2 = (2, "二年级")
    GRADE_3 = (3, "三年级")
    GRADE_4 = (4, "四年级")
    GRADE_5 = (5, "五年级")

class SemesterEnum(BaseEnum):
    """学期枚举"""
    AUTUMN = (1, "秋季学期")
    SPRING = (2, "春季学期")

class PermissionTypeEnum(BaseEnum):
    """权限类型枚举"""
    MENU = (1, "菜单")
    BUTTON = (2, "按钮")
    API = (3, "接口")

class CourseTypeEnum(BaseEnum):
    """课程类型枚举"""
    MAIN_SUBJECT = (1, "主科")
    MINOR_SUBJECT = (2, "副科")
    ACTIVITY = (3, "活动课")

class RoomTypeEnum(BaseEnum):
    """教室类型枚举"""
    NORMAL = (1, "普通教室")
    LAB = (2, "实验室")
    MULTIMEDIA = (3, "多媒体教室")
    MUSIC = (4, "音乐教室")
    ART = (5, "美术教室")

class RoleEnum(BaseEnum):
    """角色枚举"""
    ADMIN = ("ADMIN", "系统管理员")
    EDU_ADMIN = ("EDU_ADMIN", "教务管理员")
    TEACHER = ("TEACHER", "教师")
    HEAD_TEACHER = ("HEAD_TEACHER", "班主任")
    GRADE_LEADER = ("GRADE_LEADER", "年级组长")